package com.liuyang.mapper;

import com.liuyang.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandMapper {
//    查询所有
    @Select("select * from tb_brand")
    @ResultMap("brandResultMap")
    List<Brand> selectAll();

//    添加数据
    @Insert("insert into tb_brand values (null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(@Param("brand") Brand brand);

//    批量删除数据
    void deleteByIds(@Param("ids") int[] ids);

//    删除按钮
    @Delete("delete from tb_brand where id = #{id}")
    void deleteById(@Param("id") int id);

//    修改按钮
    @Select("select * from tb_brand where id = #{id}")
    @ResultMap("brandResultMap")
    List<Brand> editData(int id);

//    查询功能
    @Select("select * from tb_brand limit #{begin},#{size}")
    @ResultMap("brandResultMap")
    List<Brand> selectByPage(@Param("begin") int begin,@Param("size") int size);

//    返回总记录数
    @Select("select count(*) from tb_brand")
    int selectTotalCount();

//    搜索查询
    List<Brand> selectByPageAndCondition(@Param("begin") int begin,@Param("size") int size,@Param("brand")Brand brand);

//  通过条件查询总记录数
    int selectTotalCountByCondition(Brand brand);
}
